package com.huidatech.bootsecurity.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
* @DESC: HttpBasic登录认证模式
* @author wangzhuangzhuang
* @date 2021-10-28 16:45
*/
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
     @Override
	protected void configure(HttpSecurity httpSecurity) throws Exception{
     	httpSecurity.httpBasic() // 开启HttpBasic认证
	            .and()
		        .authorizeRequests()
		        .anyRequest()
		        .authenticated(); // 所有请求都需要登录认证才能访问
     }
}
